package com.github.yoojia.flow.support;

import com.github.yoojia.flow.Context;
import com.github.yoojia.flow.Event;
import com.github.yoojia.flow.Payload;
import com.github.yoojia.flow.VirtualDevice;

/**
 * @author 陈小锅 (yoojiachen@gmail.com)
 * @since 1.0.0
 */
public abstract class VirtualSwitchDevice extends VirtualDevice {

    public static final String TOPIC = Context.TOPIC_SWITCH;

    @Override
    final public Event handleEvent(Context context, Event request) {
        final Payload.Bool value = request.getBoolPayload();
        return handleEvent(context, request, value);
    }

    @Override
    public void onStart() {
        // nop
    }

    @Override
    public void onStop() {
        // nop
    }

    protected abstract Event handleEvent(Context context, Event request, Payload.Bool value);
}
